Importing CSV Files

Checking the Data

Fixing the Dates

## [1] "19170101" "19170102" "19170103" "19170104" "19170105" "19170106"

Checking the New Dates

## Subset Sites

## [1] OJAI CA US
## Levels: OJAI CA US

Let’s choose the BARROW W POST W ROGERS AIRPORT AK US because the record is longer than the airport.

A new plot

Evaluating the trend

Creating a linear model and then evaluate the rate (slope).

## 
## Call:
## lm(formula = TMAX ~ NewDate, data = LosAngeles)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -44.919  -9.415  -0.342   9.350  40.416 
## 
## Coefficients:
##               Estimate Std. Error  t value Pr(>|t|)    
## (Intercept)  7.807e+01  6.640e-02 1175.888  < 2e-16 ***
## NewDate     -2.658e-05  6.259e-06   -4.247 2.17e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.41 on 35529 degrees of freedom
##   (782 observations deleted due to missingness)
## Multiple R-squared:  0.0005074,  Adjusted R-squared:  0.0004793 
## F-statistic: 18.04 on 1 and 35529 DF,  p-value: 2.172e-05

Creating Month and Year Variables

So, let’s figure out how to see how changes happen for individual months.

Creating Monthly Means

##   Month Year      TMAX YEAR MONTH  NewDate
## 1    01 1917  7.069547 1917     1 1917.000
## 2    02 1917  8.784908 1917     2 1917.083
## 3    03 1917  7.809974 1917     3 1917.167
## 4    04 1917  8.435284 1917     4 1917.250
## 5    05 1917  6.535758 1917     5 1917.333
## 6    06 1917 12.658194 1917     6 1917.417

below is sd

## 
## Call:
## lm(formula = TMAX ~ NewDate, data = MonthlySD)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.5948 -1.3109 -0.1002  1.2044  7.9359 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept) 10.564453   3.578222   2.952  0.00322 **
## NewDate     -0.001456   0.001819  -0.800  0.42385   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.802 on 1182 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.0005412,  Adjusted R-squared:  -0.0003043 
## F-statistic: 0.6401 on 1 and 1182 DF,  p-value: 0.4238

Selecting for 1 Month

## 
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month == 
##     "04", ])
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -10.1433  -2.5047  -0.0938   2.8245   8.0180 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)  21.6564    25.9442   0.835   0.4059  
## YEAR          0.0267     0.0132   2.023   0.0458 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.75 on 96 degrees of freedom
## Multiple R-squared:  0.0409, Adjusted R-squared:  0.03091 
## F-statistic: 4.094 on 1 and 96 DF,  p-value: 0.04582

## 
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month == 
##     "07", ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -8.9677 -2.0630 -0.1102  2.3523  8.7120 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 191.52739   22.20627   8.625 1.24e-13 ***
## YEAR         -0.05114    0.01129  -4.529 1.69e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.238 on 97 degrees of freedom
## Multiple R-squared:  0.1745, Adjusted R-squared:  0.166 
## F-statistic: 20.51 on 1 and 97 DF,  p-value: 1.69e-05

## 
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month == 
##     "08", ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -6.8232 -1.5971 -0.0065  1.5255  8.5973 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 134.19879   20.15496   6.658 1.61e-09 ***
## YEAR         -0.02162    0.01025  -2.109   0.0375 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.958 on 98 degrees of freedom
## Multiple R-squared:  0.04343,    Adjusted R-squared:  0.03367 
## F-statistic: 4.449 on 1 and 98 DF,  p-value: 0.03746

## 
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month == 
##     "11", ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -6.8244 -3.3259  0.3259  2.7188 10.2763 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 163.69455   27.98160    5.85 6.65e-08 ***
## YEAR         -0.04539    0.01423   -3.19  0.00192 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.08 on 97 degrees of freedom
## Multiple R-squared:  0.09493,    Adjusted R-squared:  0.0856 
## F-statistic: 10.17 on 1 and 97 DF,  p-value: 0.001919

## 
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month == 
##     "12", ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -7.9694 -3.1011 -0.3825  3.0747  9.2401 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 137.85146   27.48570   5.015 2.42e-06 ***
## YEAR         -0.03572    0.01398  -2.555   0.0122 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.958 on 96 degrees of freedom
## Multiple R-squared:  0.06365,    Adjusted R-squared:  0.0539 
## F-statistic: 6.526 on 1 and 96 DF,  p-value: 0.0122

TMIN

  1. We create a monthly mean for each month.
##   Month Year     TMIN YEAR
## 1    01 1917 34.58065 1917
## 2    02 1917 35.92857 1917
## 3    03 1917 33.35484 1917
## 4    04 1917 39.46667 1917
## 5    05 1917 41.09677 1917
## 6    06 1917 51.60000 1917
  1. Now we plot the mins, and again, find tons of scatter.

## 
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month == 
##     "01", ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -8.5486 -1.7755 -0.1755  1.3592  7.8665 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept) -26.78993   19.92827  -1.344  0.18195   
## YEAR          0.03183    0.01013   3.142  0.00222 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.948 on 98 degrees of freedom
## Multiple R-squared:  0.09151,    Adjusted R-squared:  0.08224 
## F-statistic: 9.871 on 1 and 98 DF,  p-value: 0.00222

## 
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month == 
##     "03", ])
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -5.073 -1.373 -0.519  1.671  6.960 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -21.363213  17.456061  -1.224 0.224012    
## YEAR          0.031190   0.008879   3.513 0.000678 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.523 on 96 degrees of freedom
## Multiple R-squared:  0.1139, Adjusted R-squared:  0.1047 
## F-statistic: 12.34 on 1 and 96 DF,  p-value: 0.000678

## 
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month == 
##     "05", ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.6486 -1.6267  0.0623  1.6795  6.4054 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept) -5.887086  16.532669  -0.356  0.72256   
## YEAR         0.027011   0.008409   3.212  0.00179 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.39 on 96 degrees of freedom
## Multiple R-squared:  0.09704,    Adjusted R-squared:  0.08764 
## F-statistic: 10.32 on 1 and 96 DF,  p-value: 0.001794

## 
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month == 
##     "06", ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.3810 -1.2987  0.0021  1.4953  5.1190 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -23.090329  14.389683  -1.605    0.112    
## YEAR          0.037559   0.007318   5.132 1.47e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.095 on 97 degrees of freedom
## Multiple R-squared:  0.2136, Adjusted R-squared:  0.2055 
## F-statistic: 26.34 on 1 and 97 DF,  p-value: 1.47e-06

## 
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month == 
##     "07", ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.7796 -1.6199 -0.1003  1.7751  8.3318 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -14.601690  17.259527  -0.846 0.399631    
## YEAR          0.035276   0.008777   4.019 0.000116 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.516 on 97 degrees of freedom
## Multiple R-squared:  0.1427, Adjusted R-squared:  0.1339 
## F-statistic: 16.15 on 1 and 97 DF,  p-value: 0.0001155

## 
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month == 
##     "08", ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.8051 -2.0273 -0.2833  2.0279  7.7257 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -10.458953  17.113818  -0.611 0.542521    
## YEAR          0.033074   0.008702   3.801 0.000251 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.512 on 98 degrees of freedom
## Multiple R-squared:  0.1285, Adjusted R-squared:  0.1196 
## F-statistic: 14.45 on 1 and 98 DF,  p-value: 0.0002506

## 
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month == 
##     "09", ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.1896 -1.8215  0.0521  1.6751  9.3185 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -24.61825   18.66327  -1.319     0.19    
## YEAR          0.03916    0.00949   4.127 7.72e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.739 on 98 degrees of freedom
## Multiple R-squared:  0.1481, Adjusted R-squared:  0.1394 
## F-statistic: 17.03 on 1 and 98 DF,  p-value: 7.723e-05

## 
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month == 
##     "10", ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -6.1782 -1.7592 -0.3477  1.8006  6.4333 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept) -9.124970  18.153567  -0.503  0.61635   
## YEAR         0.028483   0.009232   3.085  0.00265 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.647 on 97 degrees of freedom
## Multiple R-squared:  0.08936,    Adjusted R-squared:  0.07997 
## F-statistic: 9.518 on 1 and 97 DF,  p-value: 0.002651

Experimental Portion — Precipitation

Precipiation might depend more on the departure from the mean (often referred as as normal, whatever that means!). I think it’s worth pursuing, but haven’t finished the analysis yet.

First, we need a “mean” – The IPCC uses 1961-1990 as a norm, I don’t know what is the standard for California, so we should look that up.

Second, we need to remove the missing values and evalaute which years have complete years. If you are missing rainy months, then the whole year should be thrown out – but what about partial years in the drought season?

Third, we will need to decide what level of aggredation – monthly, yearly, etc.

Fourth, in CA the water year starts in Oct 1. Should we follow the same convention?

A yearly mean, based on the annual sum for the entire records. Not sure this is appropriate.

Figure has points of the yearly sum of rainfall and the blue line mean. The greenline is the trend and red line is a five year running average, I think! I am still trying to understand what the code is doing.

## [1] 0.2 0.2 0.2 0.2 0.2

The model suggests that the precipitation is declines at a rate of -0.0119165 cm yr\(^{-1}~\), or -0.12 cm decade\(^{-1}\).

## 
## Call:
## lm(formula = PRCP ~ YEAR, data = YearlySum)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -15.517  -6.829  -2.899   5.132  27.802 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept) 43.06833   67.06418   0.642    0.522
## YEAR        -0.01192    0.03409  -0.350    0.727
## 
## Residual standard error: 9.989 on 99 degrees of freedom
## Multiple R-squared:  0.001233,   Adjusted R-squared:  -0.008856 
## F-statistic: 0.1222 on 1 and 99 DF,  p-value: 0.7274